﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public struct CacheAction
{
    private float delay;
    private float timer;
    private object data;
    private System.Action<object> callback;

    public CacheAction(object _data, System.Action<object> _callback)
    {
        delay = 0;
        timer = Time.time;
        data = _data;
        callback = _callback;
    }

    public CacheAction(float _delay, object _data, System.Action<object> _callback)
    {
        delay = _delay;
        timer = Time.time;
        data = _data;
        callback = _callback;
    }

    public void InvokeMethod()
    {
        if (callback != null)
            callback(data);
    }

    public bool IsTimeOut()
    {
        return Time.time - timer > delay;
    }
}

public class BCWAction<T> : BCWAction
{
    public delegate T GBCWObject();
    public delegate T GBCWObject<T0>(T0 arge0);
    public delegate T GBCWObject<T0, T1>(T0 arge0, T1 arge1);
    public delegate T GBCWObject<T0, T1, T2>(T0 arge0, T1 arge1, T2 arge2);
    public delegate T GBCWObject<T0, T1, T2, T3>(T0 arge0, T1 arge1, T2 arge2, T3 arge3);

    public delegate T[] GBCWArray();
    public delegate T[] GBCWArray<T0>(T0 arge0);
    public delegate T[] GBCWArray<T0, T1>(T0 arge0, T1 arge1);
    public delegate T[] GBCWArray<T0, T1, T2>(T0 arge0, T1 arge1, T2 arge2);
    public delegate T[] GBCWArray<T0, T1, T2, T3>(T0 arge0, T1 arge1, T2 arge2, T3 arge3);
}

public class BCWAction
{
    public delegate void VBCWAction();
    public delegate void VBCWAction<T0>(T0 arge0);
    public delegate void VBCWAction<T0, T1>(T0 arge0, T1 arge1);
    public delegate void VBCWAction<T0, T1, T2>(T0 arge0, T1 arge1, T2 arge2);
    public delegate void VBCWAction<T0, T1, T2, T3>(T0 arge0, T1 arge1, T2 arge2, T3 arge3);
}

